package pers.lan.linkedlist;

/**
 * @author <p><a href="mailto:1728209643@qq.com">XiaoSan</a>
 * @date 2019/9/7 7:33 PM
 */
public class ListNode {

    public int val;

    public ListNode next;

    public ListNode(int val) {
        this.val = val;
    }

    public static ListNode build(int[] vals) {
        ListNode head = new ListNode(vals[0]);
        ListNode p = head;

        for (int i = 1; i < vals.length; i++) {
            p.next = new ListNode(vals[i]);
            p = p.next;
        }

        return head;
    }

    @Override
    public String toString() {
        return
                val +
                " > " + next;
    }
}
